<template>
    <section>
        <div v-show="masterVisable">
            <sy-baselist
                    ref="list"
                    fixOperate
                    :filters="filters"
                    :showFilterCount="2"
                    @searchChange="searchChange"
                    editVue="./customer/Customer_Edit.vue"
                    listUrl="server/customer/Customer.ashx?cmd=GetList"
                    deleteUrl="server/customer/Customer.ashx?cmd=Delete"
            >
                <el-table-column prop="FName" header-align="center" label="客户名称" width="220" sortable>
                    <template scope="scope">
                        <a href="javascript:;" @click="viewCustomer(scope.row)">{{ scope.row.FName }}</a>
                    </template>
                </el-table-column>
                <el-table-column prop="FContactsInfo" header-align="center" show-overflow-tooltip label="联系人信息" width="200">
                    <template scope="scope">
                        <div style="height: 48px" v-html="scope.row.FContactsInfo"></div>
                    </template>
                </el-table-column>
                <el-table-column prop="FProjectInfo" header-align="center" show-overflow-tooltip label="项目内容及信息" width="300" >
                    <template scope="scope">
                        <div style="height: 48px" v-html="scope.row.FProjectInfo"></div>
                    </template>
                </el-table-column>
                <el-table-column prop="FTraceInfo" header-align="center" show-overflow-tooltip label="项目跟踪" width="300" >
                    <template scope="scope">
                        <div style="height: 48px" v-html="scope.row.FTraceInfo"></div>
                    </template>
                </el-table-column>
                <el-table-column prop="FGradeYX" header-align="center" label="意向客户类别" width="130">
                </el-table-column>
                <el-table-column prop="FGrade" header-align="center" label="客户类别" width="120" sortable>
                </el-table-column>
                <el-table-column prop="FGrade_1" header-align="center" label="是否申报成功" width="80">
                </el-table-column>
                <el-table-column prop="FGrade_2" header-align="center" label="是否已签单" width="80">
                </el-table-column>
                <el-table-column prop="FGrade_3" header-align="center" label="是否黑名单" width="80">
                </el-table-column>
                <el-table-column prop="FCorporation" header-align="center" label="法人" width="80">
                </el-table-column>
                <el-table-column prop="FIndustry" header-align="center" label="所属行业" width="120" sortable>
                </el-table-column>
                <el-table-column prop="FProvice" header-align="center" label="省份" width="100" sortable>
                </el-table-column>
                <el-table-column prop="FCity" header-align="center" label="城市" width="100" sortable>
                </el-table-column>
                <el-table-column prop="F10000" header-align="center" label="是否万家企业" width="100" sortable>
                </el-table-column>
                <el-table-column prop="FHeightEnergy" header-align="center" label="是否高耗能企业" width="100" sortable>
                </el-table-column>
                <el-table-column prop="UserName" header-align="center" label="归属业务员" width="160" sortable>
                </el-table-column>
                <el-table-column prop="FNote"  header-align="center" label="备注" width="250" >
                </el-table-column>
                <template v-if="isAdmin" slot="extendbtnTop">
                    <el-button type="success" size="small"  :loading="excelLoading"  @click="exportExcel()">导出Excel</el-button>
                </template>
            </sy-baselist>
        </div>
<div v-show="detailVisable">
    <el-button type="success" size="small" icon="caret-left"
               style="margin: 10px 0 0 10px" @click="back()">返回客户列表</el-button>
    <CustomerOne ref="customerOne"></CustomerOne>
</div>

    </section>
</template>

<script>
    import util from '../../common/util'
    import mixin from '../../common/mixin'
    import CustomerOne from "./Customer_One.vue"
    export default {
        mixins: [mixin],
        components:{
            CustomerOne:CustomerOne
        },
        data(){
            return {
                isAdmin:(global.user.FID==-1),
                activeTab:"tab_1",
                detailVisable:false,
                masterVisable:true,
                excelLoading:false,
                filters: [
                    {type: "string",remote:true,name:"FINDALL",text:"全文搜索"},
                    {type: "string",name:"FName",text:"客户名称"},
                    {type: "select",name:"FGrade",text:"客户类别",valueKey:"FName",equal:"like",
                        data:"server/system/SetType.ashx?cmd=GetOptions&FType=6"
                    },
                    {type: "select",name:"FGradeYX",text:"意向客户类别",
                        data:["A(1个月内签单)","B（2个月内签单）","C（3个月或以上签单）"]
                    },
                    {type: "select",name:"FIndustry",text:"所属行业",
                        data:["火电","煤炭", "石油天然气","石化","化工、医药","建筑材料","机械","电子","轻工","纺织、化纤","钢铁",
                            "有色冶金","农业","林业","通信信息","广播电影电视","水文地质","水利工程","港口河海工程",
                        "生态建设和环境工程","市政公用工程","建筑","城市规划","综合经济","公路","铁路","城市轨道交通","民航","水电","核电","其他"]},
                    {type: "select",name:"FProvice",text:"省份",valueKey:"FName",
                        data:"server/system/System.ashx?cmd=GetArea&pid=0"},
                    {type: "select",name:"FCity",text:"城市",valueKey:"FName",
                        data:"server/system/System.ashx?cmd=GetArea&pid=450000"},
                    {type: "select",name:"FUserID",text:"所属业务员",
                        data:"server/system/User.ashx?cmd=GetUserOptions"},
//                    {type: "checkbox",name:"F10000",text:"万家企业", value:[["是","是",false], ["否","否",false]]},
//                    {type: "checkbox",name:"FHeightEnergy",text:"高耗能企业", value:[["是","是",false], ["否","否",false]]},
//                    {type: "checkbox",name:"FGrade_1",text:"申报成功", value:[["是","是",false], ["否","否",false]]},
//                    {type: "checkbox",name:"FGrade_2",text:"已签约", value:[["是","是",false], ["否","否",false]]},
//                    {type: "checkbox",name:"FGrade_3",text:"黑名单", value:[["是","是",false], ["否","否",false]]}
                    {type: "select",name:"F10000",text:"是否万家企业",
                        data:["是","否"]},
                    {type: "select",name:"FHeightEnergy",text:"是否高耗能企业",
                        data:["是","否"]},
                    {type: "select",name:"FGrade_1",text:"是否申报成功",
                        data:["是","否"]},
                    {type: "select",name:"FGrade_2",text:"是否已签约",
                        data:["是","否"]},
                    {type: "select",name:"FGrade_3",text:"是否黑名单",
                        data:["是","否"]}
                ]
            }
        },
        methods:{
            exportExcel(){
                let para = this.$refs.list._wherePara();
                window.open(global.serverHost + "server/customer/Customer.ashx?cmd=ExportExcel&where=" + encodeURI(para.where));
            },
            viewCustomer(row){
                this.masterVisable = false
                this.detailVisable = true
                this.$refs.customerOne._init(row)
            },
            back(){
                this.masterVisable = true
                this.detailVisable = false
            },
            //省、城市联动
            searchChange(key,val,record){
                if(key=="FProvice"){
                   let item = this.filters.find((v,i,arr)=>{
                            return v.name=="FCity"
                    })
                    if(item){
                        item.data = "server/system/System.ashx?cmd=GetArea&pid="+(record.FID?record.FID:-1)
                    }
                }
            }
        }
    }
</script>
